package com.dzeshko.json;

import java.io.IOException;

import org.json.JSONObject;

import android.util.Log;

import com.dzeshko.http.HttpManager;

import extent.CommonAsyncTask;
import extent.ParamCallback;

public class JsonObjectFeed  extends CommonAsyncTask<JSONObject> {

	public JsonObjectFeed(ParamCallback<JSONObject> paramCallback) {
		super(paramCallback);
	}

	@Override
	public JSONObject convert(String source) throws Exception {
		if (source == null || source.length() == 0) {
			return null;
		}
		return new JSONObject(source);
}

	@Override
	protected JSONObject doInBackground(String... params) {
			Log.d("in thread:code",params[0]);
			String source;
			try {
				source = HttpManager.getInstance().httpPost(params[0]);
				return convert(source);

			} catch (IOException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			} catch (Exception e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
			return null;
	}
}